#!/bin/bash

#------- 设置变量------
es_url=http://10.244.0.53:9200
km_indices=false # 知识库索引名称，设置为false不创建索引
chat_indices=pressqa # 聊天机器人索引名称，设置为false不创建索引
itsm_indices=pressitsm # itsm索引名称，设置为false不创建索引
message_indices=pressmessage # message索引名称，设置为false不创建索引


if [ $km_indices != false ]
then
  curl -H "Content-Type: application/json" -XPUT "${es_url}"/"${km_indices}" -d @km-setting.json
  curl -H "Content-Type: application/json" -XPUT "${es_url}"/"${km_indices}"/knowledge/_mapping -d @km-mapping.json
fi

if [ $chat_indices != false ]
then
  curl -H "Content-Type: application/json" -XPUT "${es_url}"/"${chat_indices}" -d @chat-setting.json
  curl -H "Content-Type: application/json" -XPUT "${es_url}"/"${chat_indices}"/qa/_mapping -d @chat-mapping.json
fi

if [ $itsm_indices != false ]
then
  curl -H "Content-Type: application/json" -XPUT "${es_url}"/"${itsm_indices}" -d @itsm-setting.json
  curl -H "Content-Type: application/json" -XPUT "${es_url}"/"${itsm_indices}"/_mapping/event -d @itsm-mapping.json
fi

if [ $message_indices != false ]
then
  curl -H "Content-Type: application/json" -XPUT "${es_url}"/"${message_indices}" -d @message-setting.json
  curl -H "Content-Type: application/json" -XPUT "${es_url}"/"${message_indices}"/message/_mapping -d @message-mapping.json
fi
